#include "Carinha.h"

namespace gameCG {

	Carinha::Carinha() {
		speed = 0.001f;
		z = 0;
		x = 0;
	}

	float Carinha::getX() {
		return x;
	}

	float Carinha::getZ() {
		return z;
	}
	
	void Carinha::draw() {
		glPushAttrib(GL_LIGHTING_BIT);	
		GLfloat specular[] = {1.0f,1.0f,1.0f,1.0f};
		GLfloat shininess[] = {50.0f};
		glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
		glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
		glutSolidSphere(0.5f, 20, 16);
		glPopAttrib();
	}

 	void Carinha::update(int delta) {		
		if(direction == 0) {
			x += speed*delta;
			Translate(speed*delta,0.0f,0.0f);
		}
		else if(direction == 1) {
			x -= speed*delta;
			Translate(-speed*delta,0.0f,0.0f);
		}
		else if(direction == 2) {
			z += speed*delta;
			Translate(0.0f,0.0f,speed*delta);
		}
		else {
			z -= speed*delta;
			Translate(0.0f,0.0f,-speed*delta);
		}
 	}

	void Carinha::reset() {
		x = 0.0f;
		z = 0.0f;
		clearTransformations();
		speed = 0.001f;
		direction = 0;	
	}

	void Carinha::increaseSpeed() {
		speed += 0.001;
	}

	void Carinha::setDirection(int dir) {
		direction = dir;
	}
}
